welo git mirrors
Commit 06decd068aea3222174baa8a5e588e1d5b8d285a
Parents : 7ce2533
Author : welo | main nixos computer <empty@empty.com>
Date : 2026-07-04T23:54:50+01:00
started writting up filter system
Changes
3 files changed, 32 insertions(+), 8 deletions(-)
Diff
diff --git a/src/filter.rs b/src/filter.rs
new file mode 100644
index 0000000..2396398
--- /dev/null
+++ b/src/filter.rs
@@ -0,0 +1,23 @@
+///! Socket Filter
+///!
+///! This allows the server side client to restrict what ips are allowed. as well as what ports
+///!
+///! This allows for generals socksv5 proxying while for example disabling accessing the localhost or computer's private network or disabling all UDP.
+///! but can also be used for more restrictive purposes like only allowing clients to connect to a certain localhost.
+///!
+///! # Filter list
+///! the filter list consists of a list of filters which can either be include or exclude
+///! with the top having the least prioty and more granular settings and the bottom having the most priorty.
+///!
+///! by defeault an addressj
+///!
+///! # examples
+///! ## example 1, only allow dns requests
+/// All:53:udp Include
+///! ## example 2, allow connections only to a local IRC chat
+/// All:194 Include
+///! ## example 3, generic sockets server that blocks udp, private and localhost except for a localhost web server
+/// All Include
+/// Private Exclude
+/// Localhost Exclude
+/// Localhost:80:tcp
diff --git a/src/relay.rs b/src/relay.rs
index 1bb10a4..9c3c867 100644
--- a/src/relay.rs
+++ b/src/relay.rs
@@ -90,6 +90,7 @@ pub async fn relay_bidirectional_udp(
// to go, so we don't have to add that in ourselves, however on the server side RNS, when
// the server receives a packet from a remote destination, it must wrap the udp packet with
// the original location where that packet came from so the client knows of that information.
+ // that's on the UDP -> RNS side, on the other side it's reversed.
) {
let socket = Arc::new(socket);
let socket1 = socket.clone();
@@ -110,6 +111,9 @@ pub async fn relay_bidirectional_udp(
//
// I might just be being stupid but I can't find a better way of figuring this out. and the spec
// is pretty vague so https://www.rfc-editor.org/info/rfc1928/
+ //
+ // you could probably do better than using a mutex cause it's only updated in one thread
+ // and read in another, but I odn't know enough fancy rust stuff to actually do that.
// UDP -> RNS
@@ -155,7 +159,6 @@ pub async fn relay_bidirectional_udp(
if wrap_packets {
match frame.frame_type {
FrameType::Data => {
-
let a = client_local_port_2.lock().await;
let value = *a;
@@ -171,10 +174,9 @@ pub async fn relay_bidirectional_udp(
} else {
warn!("UDP received but client side does not know of a port");
// break // shouldn't break because this might not be the client's fault
+ // maybe some random bot send a udp request to that port before the client
+ // could do anything, so we just leave it open.
}
-
-
-
}
FrameType::Close => {println!("frame closed {:?}", frame); break},
_ => {}
diff --git a/src/server.rs b/src/server.rs
index a47bb18..c21afe3 100644
--- a/src/server.rs
+++ b/src/server.rs
@@ -237,10 +237,9 @@ async fn handle_server_session_udp(
) {
// Attempt UDP "connection"
- // temp 0.0.0.0 address till I figure that you can actually do this
- // here an empty port number means the OS gets to handle the exact port, we then connnect with our real info
-
- let socket = match UdpSocket::bind("0.0.0.0:0").await {
+ // generally the udp socket will connect to 0.0.0.0:0 to allow to send and receive from
+ // every port. We don't police which sockets are valid here.
+ let socket = match UdpSocket::bind(format!("{}:{}",host,port)).await {
Ok(s) => s,
Err(e) => {
warn!("[{}] udp bind failed 1: {}", sid, e);
Served by rngit 1.4.2 - Generated in 0.03s